#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    QDateTime time1 = ui->dateTimeEdit->dateTime();
    QDateTime time2 = ui->dateTimeEdit_2->dateTime();

//    int days = time1.daysTo(time2);
    int sec = time1.secsTo(time2);
    int days = (sec / 3600) / 24;
    int hours = (sec / 3600) % 24;

    ui->label->setText("相差" + QString::number(days) + "天" + QString::number(hours) + "小时");
}
